package com.network.task;

import com.network.util.FtpUtils;
import org.springframework.beans.factory.annotation.Value;

public class FtpUploadTask implements Runnable
{

    // ftp服务器地址
    private String hostname = "192.168.1.100"; //TODO 换上你的地址
    // ftp服务器端口号默认为21
    private Integer port = 21;
    // ftp登录账号
    private String username = "98k"; //TODO 换上你的用户名

    // ftp登录密码
    private String password = "123"; //TODO 换上你的密码

    //ftp目录
    private String path;

    @Value("${file.basePath}")
    private String basePath;

    public FtpUploadTask(String hostname, Integer port, String username, String password,String path) {
        this.hostname = hostname;
        this.port = port;
        this.username = username;
        this.password = password;
        this.path=path;
    }

    @Override
    public void run()
    {
        FtpUtils ftpUtil= FtpUtils.getInstance();
        ftpUtil.hostname=hostname;
        ftpUtil.username=username;
        ftpUtil.port=port;
        ftpUtil.password=password;

        boolean isok=false;

        while (!isok)
        {
            isok=ftpUtil.downloadDir("/filetest/",basePath,"/");
        }
        System.out.printf("*********完成");
    }
}
